import os
from pathlib import Path


# 获取文件的路径
def get_file_dir(filename):
    # 获取项目根目录
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    file_dir = os.path.join(dir_, f"{filename}")
    return file_dir


def get_config_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    config_dir = os.path.join(dir_, "config")
    return config_dir


def yaml_dir(file_path):
    file_dir = os.path.join(get_file_dir("testdata"), f"{file_path}")
    return file_dir


# 获取测试报告的文件路径
def get_report_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    report_dir = os.path.join(dir_, f"allure-report")
    return report_dir


# 获取测试用例数据库路径
def get_allure_results_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    allure_results = os.path.join(dir_, f"allure-results")
    return allure_results


# 获取测试用例的文件路径
def get_testcase_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    config_dir = os.path.join(dir_, "testcase")
    return config_dir


# 获取测试用例的文件路径
def get_testdata_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    config_dir = os.path.join(dir_, "testdata")
    return config_dir


def get_template_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    template_dir = os.path.join(dir_, "streamlit_app/templates")
    return template_dir


def get_captcha_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    captcha_dir = os.path.join(dir_, "captcha.png")
    return captcha_dir


def get_model_template_dir(filename):
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    template_dir = os.path.join(dir_, f"large_model/date_template/{filename}")
    return template_dir


def get_time_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    time_dir = os.path.join(dir_, "last_generate_time.txt")
    return time_dir


# 封装读取doc接口文件
def get_doc_md_dir(filename):
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    doc_dir = os.path.join(dir_, f"large_model/model_read_file/{filename}")
    return doc_dir


def get_xmind_dir():
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    doc_dir = os.path.join(dir_, f"streamlit_model/streamlit_files/xmind")
    return doc_dir


def get_xmind_file_dir(filename):
    dir_ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    xmind_file_dir = os.path.join(dir_, f"streamlit_model/streamlit_files/xmind/{filename}")
    return xmind_file_dir
